package com.dongway.netcondition.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.dongway.core.common.ValidationException;
import com.dongway.core.service.BaseService;
import com.dongway.netcondition.model.SystemProperty;


@Service
public class SystemPropertyService extends BaseService{

    public List<SystemProperty> all() {
        String sql = "select * from t_system_property";
        return getDao().query(SystemProperty.class, sql);
    }
    
    public SystemProperty searchByName(String name) {
        String sql = "select * from t_system_property where p_name=?";
        return getDao().queryForObject(SystemProperty.class, sql, name);
    }
    
    public void update(SystemProperty systemProperty) {
        if (StringUtils.isBlank(systemProperty.getPName())) {
            throw new ValidationException("参数名不能为空");
        }
        getDao().updateIgnoreNull(systemProperty);
    }
}
